package com.changpay.zywy.ui.activity.count;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.changpay.zywy.R;
import com.changpay.zywy.wight.WheelCircleView;

/**
 * Created by AndroidIntexh1 on 2018/12/20.
 */

public class CountActionTotalView extends RelativeLayout {

    RelativeLayout rvMore;
    TextView tvTitle;
    ImageView ivMore;
    LinearLayout llContent;

    TextView tvTotalALL;  // 本月机具总数
    TextView tvActionAct;  // 总激活数
    TextView tvActionUnaction;  // 总未激活数
    WheelCircleView ct_action_all;  // 总比例饼图


    TextView tv_h9_add_count;  // H9+激活数
    TextView tv_mp70_add_count; // mp70+激活数
    TextView tv_zhibieji_count; // 自备机激活数
    TextView tv_h9_count;  // h9激活数
    TextView tv_mp70_count; // mp70激活数
    WheelCircleView ct_action_per;  // 激活比例饼图
    WheelCircleView ct_action_per_two;  // 激活比例饼图

    CountChartActionClose countChartOtherClose;
    public boolean isDisplay = false;


    private View view;


    public CountActionTotalView(Context context) {
        this(context, null);
    }

    public CountActionTotalView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs);
    }

    private void init(Context context, AttributeSet attrs) {

        view = View.inflate(context, R.layout.count_item_total_action, this);

        rvMore = view.findViewById(R.id.rv_more);
        tvTitle = view.findViewById(R.id.tv_title);
        llContent = view.findViewById(R.id.llContent);

        tvTotalALL = view.findViewById(R.id.tv_action_all);
        tvActionAct = view.findViewById(R.id.tv_action_act);
        tvActionUnaction = view.findViewById(R.id.tv_action_unact);
        ct_action_all = view.findViewById(R.id.ct_action_all);

        tv_h9_add_count = view.findViewById(R.id.tv_h9_add_count);
        tv_mp70_add_count = view.findViewById(R.id.tv_mp70_add_count);
        tv_zhibieji_count = view.findViewById(R.id.tv_zhibieji_count);
        tv_h9_count = view.findViewById(R.id.tv_h9_count);
        tv_mp70_count = view.findViewById(R.id.tv_mp70_count);
        ct_action_per = view.findViewById(R.id.ct_action_per);
        ct_action_per_two = view.findViewById(R.id.ct_action_per_two);


    }

    public void setData(int all ,int allAction, int allUnAction, int h9AddAction, int mp70AddAction, int zhibeijiAction, int h9Action, int mp70Action) {
        tvTotalALL.setText(String.valueOf(all) + "台");
        tvActionAct.setText(String.valueOf(allAction) + "台");
        tvActionUnaction.setText(String.valueOf(allUnAction) + "台");
        tv_h9_add_count.setText(h9AddAction + "台");
        tv_mp70_add_count.setText(mp70AddAction + "台");
        tv_zhibieji_count.setText(zhibeijiAction + "台");
        tv_h9_count.setText(h9Action + "台");
        tv_mp70_count.setText(mp70Action + "台");
        initAllChart(ct_action_all,allAction, allUnAction);
        initPerChart(ct_action_per,h9AddAction, mp70AddAction);
        initPerChart(ct_action_per_two,mp70AddAction, h9AddAction);
    }

    private void initAllChart(WheelCircleView chart, int allAction, int allUnAction) {
        chart.setDataDan(allAction,allUnAction);
    }

    private void initPerChart(WheelCircleView chart, int h9AddAction, int mp70AddAction) {
        chart.setDataDan(h9AddAction,mp70AddAction);
    }




    public void setListener(CountChartActionClose listener) {
        countChartOtherClose = listener;
    }

    public void setTitle(String title) {
        if (tvTitle != null) tvTitle.setText(title);
    }

    public interface CountChartActionClose {

        void loadActionCharData();
    }


}
